/*
 * Copyright (c) 2006, 2022, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.time.LocalDate;

/**
 * <p>Project: javase202202 - Switch5
 * <p>Powered by Lisi On 2022-06-01 10:23:15
 * <p>Created by IntelliJ IDEA
 *

 * @version 1.0
 * @since 17
 */
public class Switch7 {
    public static void main(String[] args) {
        //switch表达式 java12开始
        System.out.println(System.getProperty("java.version"));

        int y = 2022;
        int m = 2;
        int days = 0;
        switch (m) {
            case 2 -> {
                days = LocalDate.of(y, m, 1).isLeapYear() ? 29 : 28;
            }
            case 4, 6, 9, 11 -> {
                days = 30;
            }

            default -> {
                days = 31;
            }
        }

        System.out.printf("%d年%d月有%d天", y, m, days);


    }
}
